Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

feat: show error if library cannot be connected #543

Merged
merged 3 commits into from
Jun 14, 2018

Conversation

tilmx
Copy link
Member

@tilmx tilmx commented Jun 10, 2018

If the user tries to connect a library folder that does not work, we should give him a warning about that.

should be squashed into feat: show error if library cannot be connected

@tilmx tilmx requested a review from marionebl June 10, 2018 10:35
@tilmx tilmx requested a review from lkuechler June 10, 2018 11:25
library.assignPropertyId(patternId, contextId),
getGlobalSlotId: (patternId, contextId) => library.assignSlotId(patternId, contextId)
});
let analysis;
Copy link
Contributor

@marionebl marionebl Jun 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's avoid the let binding by defining a getAnalysis function that returns a AnalysisResult:

type AnalysisResult =
  | AnalysisError
  | AnalysisSuccess;

enum AnalysisState {
   Error,
   Success
}

interface AnalysisError {
   state: AnalysisState.Error;
   error: Error;
}

interface AnalysisSuccess {
   state: AnalysisState.Success;
   analysis: Analysis;
}

const getAnalysis = async (path: string; context: AnalysisContext): Promise<AnalysisResult> => {
  try {
    return { state: AnalysisState.Sucess, analysis: Analyzer.analyze(path, context) };
  } catch (error) {
    return { state: AnalysisState.Error, error };
  }
};

This can be used like this then:

const analysisResult = await getAnalysis(/* omitted */);


if (analysisResult.state === AnalysisState.Success) {
   // send 
}

if (analysisResult.state === AnalysisState.Error) {
   // show dialog
}

@tilmx tilmx changed the title feat: show error if library cannot be connected WIP feat: show error if library cannot be connected Jun 10, 2018
@tilmx
Copy link
Member Author

tilmx commented Jun 14, 2018

@marionebl I changed it to try both the analysis and the Sender.Send to avoid any let: analysis; thingies.

@tilmx tilmx changed the title WIP feat: show error if library cannot be connected feat: show error if library cannot be connected Jun 14, 2018
@marionebl marionebl merged commit 9ff88e9 into master Jun 14, 2018
@marionebl marionebl deleted the feat/show-library-error branch June 14, 2018 18:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants